package controller;

import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;

import main.RunGame;
import view.overlay.ResetOverlay;
import view.overlay.ResetOverlay.FadeCallback;

public class ResetController extends Controller {

	
	private RunGame mMainGame;
	
	private GameControl mResetControl;
	private ResetOverlay mOverlay;
	
	public ResetController(RunGame main, ResetOverlay reset) {
		mOverlay = reset;
		mMainGame = main;
		
		
		mOverlay.setCallback(new FadeCallback() {

			@Override
			public void fadeComplete() {
				// make the overlay invisible
				mOverlay.setVisible(false);
				// reset the main game
				mMainGame.restart();
				
			}
			
		});
		
		mResetControl = new GameControl(KeyEvent.VK_F12, "DEBUG_RESET", "Resets the game.") {
			
			@Override
			public void execute() {
				mOverlay.show();
				mOverlay.fadeOut();
			}
		};
		
		mOverlay.setVisible(false);
	}
	
	
	@Override
	public List<GameControl> getKeyControls() {
		List<GameControl> ctrls = new ArrayList<GameControl>();
		
		ctrls.add(mResetControl);
		mResetControl.setEnabled(false);
		
		return (ctrls);
	}
	
	@Override
	public void reset() {
		// do nothing
	}

}
